import GeoJSON from "ol/format/GeoJSON";

export function sortFeature(json) {
    var resultdata=[]
    var jbntgeocount=0
    var jsydgeocount=0
    var kggeocount=0
    var czjsgeocount=0
    // var tdytgeocount=0
    var czghgeocount=0


    for(let i=0;i<json.totalFeatures;i++){
        let features=new GeoJSON().readFeature(JSON.stringify(json.features[i]));
        var layername=features.getId().substr(0,features.getId().indexOf('.'))
        if(features.getId().indexOf('.')!=-1){
            switch (layername) {
                case 'wj_jbntbhq2022':

                    jbntgeocount++;
                    break;
                case 'wj_jsydgzq2022':
                    if(features.getProperties().GZQLXDM!='010'){
                        jsydgeocount++;
                    }
                    break;
                case 'wj_konggui2022':

                    if(features.getProperties().YDDM.indexOf('M')!=-1||features.getProperties().YDDM.indexOf('W')!=-1){

                    }else{
                        kggeocount++;
                    }

                    break;
                case 'wj_czjskzq2022':

                    czjsgeocount++;
                    break;
                // case 'wj_tdytq2022':
                //     tdytgeocount++;
                //     break;
                case 'wjczgh2018_2020':
                    if(features.getProperties().YDXZ.indexOf('V3')!=-1){

                    }else{
                        czghgeocount++;
                    }

                    break;
            }
        }
        //添加几何数组重绘
        // feasarr.push(features);
    }
    resultdata.push(
        {
            name: '建设用地管制区',
            serverurl:'http://218.93.116.192:8087/geoserver/xf/wms',
            layername:'xf:wj_jsydgzq2022',
            value:jsydgeocount
        },
        {
            name: '基本农田保护区',
            serverurl:'http://218.93.116.192:8087/geoserver/xf/wms',
            layername:'xf:wj_jbntbhq2022',
            value:jbntgeocount
        },
        {
            name: '控制性详细规划',
            serverurl:'http://218.93.116.192:8087/geoserver/xf/wms',
            layername:'xf:wj_konggui2022',
            value:kggeocount
        },
        {
            name: '村镇建设控制区',
            serverurl:'http://218.93.116.192:8087/geoserver/xf/wms',
            layername:'xf:wj_czjskzq2022',
            value:czjsgeocount
        },
        {
            name: '武进村庄规划',
            serverurl:'http://218.93.116.192:8087/geoserver/xf/wms',
            layername:'xf:wjczgh2018_2020',
            value:czghgeocount
        }
        // ,
        // {
        //     name: '土地用途区',
        //     serverurl:'http://218.93.116.192:8087/geoserver/xf/wms',
        //     layername:'xf:wj_tdytq2022',
        //     value:tdytgeocount
        // }
        )
    // resultdata.cnname='基本农田保护区'
    // resultdata.featurecount=jbntgeocount
    // resultdata.serverurl=
    // resultdata.建设用地管制区=jsydgeocount
    // resultdata.控制性详细规划=kggeocount
    // resultdata.村镇建设控制区=czjsgeocount
    // resultdata.土地用途区=tdytgeocount
    return resultdata

}
